package events

import "github.com/google/uuid"

type ProductCreatedEvent struct {
	BaseEvent
	ProductID uuid.UUID `json:"product_id"`
	Name      string    `json:"name"`
	Price     float64   `json:"price"`
	Stock     int       `json:"stock"`
}

func NewProductCreatedEvent(productID uuid.UUID, name string, price float64, stock int) *ProductCreatedEvent {
	return &ProductCreatedEvent{
		BaseEvent: NewBaseEvent(),
		ProductID: productID,
		Name:      name,
		Price:     price,
		Stock:     stock,
	}
}

func (e *ProductCreatedEvent) EventName() string {
	return "product.create"
}

// ProductStockUpdateEvent 商品库存更新事件
type ProductStockUpdateEvent struct {
	BaseEvent
	ProductID uuid.UUID `json:"product_id"`
	Quantity  int       `json:"quantity"`
	NewStock  int       `json:"new_stock"`
}

func NewProductStockUpdateEvent(productID uuid.UUID, quantity int, newStock int) *ProductStockUpdateEvent {
	return &ProductStockUpdateEvent{
		BaseEvent: NewBaseEvent(),
		ProductID: productID,
		Quantity:  quantity,
		NewStock:  newStock,
	}
}

func (e *ProductStockUpdateEvent) EventName() string {
	return "product.stock_update"
}

type ProductUpdatePriceEvent struct {
	BaseEvent
	ProductID uuid.UUID `json:"product_id"`
	OldPrice  float64   `json:"old_price"`
	NewPrice  float64   `json:"new_price"`
}

func NewProductUpdatePriceEvent(productID uuid.UUID, oldPrice, newPrice float64) *ProductUpdatePriceEvent {
	return &ProductUpdatePriceEvent{
		BaseEvent: NewBaseEvent(),
		ProductID: productID,
		OldPrice:  oldPrice,
		NewPrice:  newPrice,
	}
}

func (e *ProductUpdatePriceEvent) EventName() string {
	return "product.update_price"
}
